<template>
  <div class="content">
    <div class="index-header-box" id="head">
      <div class="index-header">
        <div @click="$router.back(-1)" class="back">
          <van-icon name="arrow-left"/>
        </div>
        <div class="title">完整配置信息</div>
      </div>
    </div>

    <van-collapse v-model="activeNames">

        <template v-for="(item,index) in exps">
          <van-collapse-item class="tool-title" v-if="checkKey(index)" :title="checkKey(index)" :name="index">

            <template v-for="(items,key) in info" v-if="keys[index].indexOf(key) != -1">

              <div class="item-list" v-if="key!='series_thumb'">
                <span class="list-tit pull-left">{{menu[key]}}</span>
                <span class="list-txt pull-right">{{items}}</span>
              </div>

            </template>

          </van-collapse-item>
        </template>



    </van-collapse>




  </div>
</template>

<script>

  export default {
    name: "tool",
    components: {
    },
    data() {
      return {
          activeNames:[
              'brand',
              'car_ckg',
              'car_engine_numb',
              'car_dwgs',
              'car_jdfs',
              'car_qzdqnx',
              'car_qaqql',
              'car_qhld',
              'car_tc_lx',
              'car_fxpcz',
              'car_zycz',
              'car_zkcsyjp',
              'car_jgdgy',
              'car_qhddcc',
              'car_ktwdkz',
            ],


          id:this.$route.query.id||0,

          info:[],
          menu:[],

          exps:{
              'brand':'基本参数',
              'car_ckg':'车身',
              'car_engine_numb':'发动机',
              'car_dwgs':'变速箱',
              'car_jdfs':'底盘转向',
              'car_qzdqnx':'车轮制动',
              'car_qaqql':'主/被动安全装备',
              'car_qhld':'辅助/操控配置',
              'car_tc_lx':'外部/防盗配置',
              'car_fxpcz':'内部配置',
              'car_zycz':'座椅配置',
              'car_zkcsyjp':'多媒体配置',
              'car_jgdgy':'灯光配置',
              'car_qhddcc':'玻璃/后视镜',
              'car_ktwdkz':'空调/冰箱',
          },

          keys:{
              'brand':{},
              'car_ckg':{},
              'car_engine_numb':{},
              'car_dwgs':{},
              'car_jdfs':{},
              'car_qzdqnx':{},
              'car_qaqql':{},
              'car_qhld':{},
              'car_tc_lx':{},
              'car_fxpcz':{},
              'car_zycz':{},
              'car_zkcsyjp':{},
              'car_jgdgy':{},
              'car_qhddcc':{},
              'car_ktwdkz':{},
          },
      }
    },
    computed: {},
    mounted: function () {
       this.init();
    },
    methods: {
       init(){
           var that=this;

           this.$api.car.getPkList({id:this.id}).then(res=>{
               var res=res.data.data;

               this.info=res.list[0]["car"];

               var c=0;
               var arr=[];
               Object.keys(this.info).forEach((key, i) => {
                   if(key=="car_ckg"){
                       c=1;
                       that.keys["brand"]=arr;
                       arr=[];
                   }
                   if(key=="car_engine_numb"){
                       c=2;
                       that.keys["car_ckg"]=arr;
                       arr=[];
                   }
                   if(key=="car_dwgs"){
                       c=3;
                       that.keys["car_engine_numb"]=arr;
                       arr=[];
                   }
                   if(key=="car_jdfs"){
                       c=4;
                       that.keys["car_dwgs"]=arr;
                       arr=[];
                   }
                   if(key=="car_qzdqnx"){
                       c=5;
                       that.keys["car_jdfs"]=arr;
                       arr=[];
                   }
                   if(key=="car_qaqql"){
                       c=6;
                       that.keys["car_qzdqnx"]=arr;
                       arr=[];
                   }
                   if(key=="car_qhld"){
                       c=7;
                       that.keys["car_qaqql"]=arr;
                       arr=[];
                   }
                   if(key=="car_tc_lx"){
                       c=8;
                       that.keys["car_qhld"]=arr;
                       arr=[];
                   }
                   if(key=="car_fxpcz"){
                       c=9;
                       that.keys["car_tc_lx"]=arr;
                       arr=[];
                   }
                   if(key=="car_zycz"){
                       c=10;
                       that.keys["car_fxpcz"]=arr;
                       arr=[];
                   }
                   if(key=="car_zkcsyjp"){
                       c=11;
                       that.keys["car_zycz"]=arr;
                       arr=[];
                   }
                   if(key=="car_jgdgy"){
                       c=12;
                       that.keys["car_zkcsyjp"]=arr;
                       arr=[];
                   }
                   if(key=="car_qhddcc"){
                       c=13;
                       that.keys["car_jgdgy"]=arr;
                       arr=[];
                   }
                   if(key=="car_ktwdkz"){
                       c=14;
                       that.keys["car_qhddcc"]=arr;
                       arr=[];
                   }

                   if(c==0) arr.push(key);
                   if(c==1) arr.push(key);
                   if(c==2) arr.push(key);
                   if(c==3) arr.push(key);
                   if(c==4) arr.push(key);
                   if(c==5) arr.push(key);
                   if(c==6) arr.push(key);
                   if(c==7) arr.push(key);
                   if(c==8) arr.push(key);
                   if(c==9) arr.push(key);
                   if(c==10) arr.push(key);
                   if(c==11) arr.push(key);
                   if(c==12) arr.push(key);
                   if(c==13) arr.push(key);
                   if(c==14) arr.push(key);
               });
               that.keys["car_ktwdkz"]=arr;

               this.menu=res.menu;
           });
       },

        checkKey(key){
            if(this.exps[`${key}`]!=undefined && this.exps[`${key}`]!="undefined"){
                return this.exps[`${key}`];
            }else{
                return false;
            }
        },
    },
  }
</script>

<style lang="scss" scoped>
  @import "../../assets/scss/index.scss";
</style>
